<template>
  <div class="currencyPage">
    <el-row>
      <el-col :span="8" :offset="16" align="right">
        <el-button type="primary" icon="el-icon-refresh" @click="refresh">货币同步</el-button>
      </el-col>
    </el-row>

    <el-table class="tableList" :data="currencyData" stripe height="85%">
      <el-table-column prop="id" label="ID" align="center"></el-table-column>
      <el-table-column prop="c_name" label="货币名称" align="center"></el-table-column>
      <el-table-column prop="c_simple_name" label="货币简称" align="center"></el-table-column>
      <el-table-column prop="c_pre_mark" label="前置货币符号" align="center"></el-table-column>
      <el-table-column prop="c_next_mark" label="后置货币符号" align="center"></el-table-column>
      <el-table-column prop="update_time" label="更新时间" align="center"></el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      @current-change="pageChange"
    ></el-pagination>
  </div>
</template>

<script>
import Service from "../../services/main";
export default {
  name: "Currency",
  data() {
    return {
      currencyData: [],
      page: 1,
      total: null
    };
  },
  created() {
    this.getCurrencyFn();
  },
  methods: {
    // 货币列表
    getCurrencyFn(type) {
      Service.getCurrencyList(this, { page: this.page }).then(res => {
        this.currencyData = res.result.list;
        this.total = res.result.total;
        this.page = res.result.page;
        if (type == "refresh") {
          this.$message({ message: "同步成功！", type: "success" });
        }
      });
    },

    // 货币同步
    refresh() {
      this.getCurrencyFn("refresh");
    }
  }
};
</script>

<style lang="scss" scoped>
.currencyPage {
  height: 100%;
}
</style>